import request from '@/router/axios';
import { curApp } from '../config/env';

export function roleList() {
  return request({
    url: '/clientauth/role/roleList',
    method: 'get'
  });
}

export function fetchList(query) {
  return request({
    url: '/clientauth/role/rolePage',
    method: 'get',
    params: query
  });
}

export function deptRoleList(deptId) {
  return request({
    url: '/clientauth/role/roleList/' + deptId,
    method: 'get'
  });
}

export function getObj(id) {
  return request({
    url: '/clientauth/role/' + id,
    method: 'get'
  });
}

export function addObj(obj) {
  return request({
    url: '/clientauth/role/',
    method: 'post',
    data: obj
  });
}

export function putObj(obj) {
  return request({
    url: '/clientauth/role/',
    method: 'put',
    data: obj
  });
}

export function delObj(id) {
  return request({
    url: '/clientauth/role/' + id,
    method: 'delete'
  });
}

export function permissionUpd(roleId, menuIds, appId) {
  return request({
    url: '/clientauth/role/roleMenuUpd',
    method: 'put',
    params: {
      roleId: roleId,
      menuIds: menuIds,
      appId: appId
    }
  });
}

export function permissionAppUpd(roleId, appIds) {
  return request({
    url: '/clientauth/role/roleAppUpd',
    method: 'put',
    params: {
      roleId: roleId,
      appIds: appIds
    }
  });
}

export function fetchRoleTree(roleName, appId) {
  return request({
    url: '/clientauth/menu/roleTree/' + roleName + '/' + appId,
    method: 'get'
  });
}

export function fetchDeptTree(query) {
  return request({
    url: '/clientauth/dept/tree',
    method: 'get',
    params: query
  });
}
